#include "LexicalAnalyzer.h"
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <sstream>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main()
{

char currentChar;
string currentString;
stringstream ss;
string charToString;
results resultsStruct;


//create a file to write the results to
  ofstream resultsFile;
  resultsFile.open ("output.txt");

//open the input file. This file for the LA should contain code. Like if(x){x=y;}...
  ifstream inputFile ("input.txt");
  if (inputFile.is_open())//if we were able to open the file..
  {
    while( !(inputFile.eof()) )//while it's not the end of file...
    {
		//Extracts a character from the stream and stores it in currentChar:
		currentChar = inputFile.get();
		//prints each character to output.txt FOR NOW FOR TESTING...
		resultsFile<<currentChar;

		if(currentChar != ((' ')||('\n')||('\0')||('c')||('\r'))) //assuming things are seperated by spaces or by new lines
		{
		cout<<currentChar;	//for testing
			string charToString(1, currentChar); //convert currentChar to String (charToString)
		currentString.append(charToString); //add current Character to current String
		}else{
			cout<<"else";	//****************FOR SOME REASON THE LOOP IS NOT GOING HERE
		//else, meaning there is a seperation, for example by a space.
		//loop is done, we have our first string to evaluate that is between seperators.
		//now we need to check to see what that string is.
				if(is_keyword(currentString))
				{
					//blah
					resultsStruct.lexeme=currentString;
					resultsStruct.token="keyword";
					cout << resultsStruct.token << "\t\t" << resultsStruct.lexeme << "\n";
				}
		}
		
    }
	
    inputFile.close();
	resultsFile.close();
  }
  else cout << "Unable to open file"; 

/////////////////

  


	return 0;
}